#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve()
{
    ll n;
    cin >> n;
    vector<int> a = { 3,5,9,15,21,25,27 };
    ll ans = (n - 1) / 7 * 30 + a[(n - 1) % 7];
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}